import java.util.Scanner;

public class Demo3 {
    private static volatile int n;  //用volatile修饰变量
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            while (n==0){

            }
            System.out.println("t1线程结束循环");
        });
        Thread t2=new Thread(()->{
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入一个整数");
            n=scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
